
<div class="breadcrumb d-flex align-items-center px-3">
    <div class="btn btn-icon me-3 js-back" aria-label="返回" role="button" tabindex="0">
        <i class="iconfont icon-left-arrow"></i>
    </div>
    <h2 class="fs-18"><?= $user->username ?></h2>
</div>

<?php include '_user_cover.php' ?>

<?php if(!$replies[0]): ?>
    <div class="placeholder fs-28">无</div>
<?php else: ?>
<ul class="list-unstyled chat p-3 border-bottom">
    <?php foreach ($replies[0] as $reply): ?>
    <?php if($reply->user_id !== session('user_id')): ?>
    <li class="others mr-4">
        <div class="chat-item">
            <img class="avatar chat-avatar" src="/img/avatar.png" alt="">
            <div>
                <div class="chat-content"><?= $reply->content ?></div>
                <span class="fs-14 text-muted"><?= $reply->post_user_id ?> · <?= nice_time($reply->post_created_at) ?></span>
            </div>
        </div>
    </li>
    <?php else: ?>
    <li class="others mr-4">
        <div class="chat-item">
            <img class="avatar chat-avatar" src="/img/avatar.png" alt="">
            <div>
                <div class="chat-content"><?= $reply->title ?></div>
                <span class="fs-14 text-muted"><?= $reply->post_user_id ?> · <?= nice_time($reply->post_created_at) ?></span>
            </div>
        </div>
    </li>
    <li class="self mb-3">
        <div class="chat-item">
            <img class="avatar chat-avatar" src="/img/avatar.png" alt="">
            <div>
                <div class="chat-content"><?= $reply->content ?></div>
                <span class="fs-14 text-muted"><?= nice_time($reply->created_at) ?> · <?= $reply->username ?></span>
            </div>
        </div>
    </li>
    <?php endif ?>
    <?php endforeach ?>
</ul>
<?php endif ?>

<?php if($replies[1]->totalRows > $replies[1]->eachPage): ?>
<nav aria-label="Page navigation">
    <ul class="pagination justify-content-center p-3">
        <li class="page-item"><a class="page-link" href="<?= $replies[1]->prevPage;?>"><span aria-hidden="true">&lsaquo;</span></a></li>
<?php foreach($replies[1]->listPage as $k=>$v): ?>
    <?php if($k == $replies[1]->currentPage): ?>
        <li class="page-item"><a class="page-link active" href="<?= $v ?>"><?= $k ?></a></li>
    <?php else: ?>
        <li class="page-item"><a class="page-link" href="<?= $v ?>"><?= $k ?></a></li>
    <?php endif ?>
<?php endforeach ?>
        <li class="page-item"><a class="page-link" href="<?= $replies[1]->nextPage;?>"><span aria-hidden="true">&rsaquo;</span></a></li>
    </ul>
</nav>
<?php endif ?>

<script>
    document.addEventListener("DOMContentLoaded", (e) => {
        // 当前链接添加 active
        highlightActiveLink("user");
        document.getElementById("my-replies").classList.add('active');
    });
</script>